<link rel="stylesheet" type="text/css" href="${rc.contextPath}/assets/ui/jww/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="${rc.contextPath}/assets/ui/jww/themes/${theme}/jww.min.css" />
<link rel="stylesheet" type="text/css" href="${rc.contextPath}/assets/customercss/themes/${theme}/common.css" />
<script type="text/javascript" src="${rc.contextPath}/assets/ui/jww/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${rc.contextPath}/assets/ui/jww/json2.js"></script>
<script type="text/javascript" src="${rc.contextPath}/assets/ui/jww/jww.min.js"></script>
<script type="text/javascript" src="${rc.contextPath}/assets/ui/jww/locale/jww-lang-zh_CN.js"></script>
<script type="text/javascript">
	var webApp = "${rc.contextPath}";
    function ajaxLoading(coverObj) {
	    var obj = null;
	    if (coverObj != undefined && coverObj != null) {
		    obj = coverObj;
	    } else {
		    obj = $(document.body);
	    }
	    $("<div class=\"loading-mask\"></div>").css({
	        display : "block",
	        width : document.body.clientWidth,
	        height : window.screen.height
	    }).appendTo(obj);
	    $("<div class=\"loading-mask-msg\"></div>").html(msgStore["loadMsg"]).appendTo(obj).css({
	        display : "block",
	        left : (obj.outerWidth(true) - 190) / 2,
	        top : (obj.height() - 45) / 2
	    });
    }
    function ajaxLoadEnd() {
	    $(".loading-mask").remove();
	    $(".loading-mask-msg").remove();
    }
    function dateFormatter(v) {
	    var d = new Date(v);
	    if (isNaN(d)) {
		    return v;
	    } else {
		    var month = d.getMonth() + 1;
		    return d.getFullYear() + "-" + month + "-" + d.getDay();
	    }
    }
    //弹出窗口,option 中的参数格式{"windowId":"windowId","wtype":"iframe","url":"xxx"}
    function openWindow(options) {
	    var window = null;
	    if (options.wtype && options.wtype == "iframe") {
		    var iframe = '<iframe src="'
		            + options.url
		            + '" width="100%" height="99.2%" style="overflow: hidden;" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes"> </iframe>';
		    if ($("#" + options.windowId).length > 0) {
			    clearIframe($("#" + options.windowId).find("iframe")[0]);
			    $("#" + options.windowId).remove();
		    }
		    var windowHtml = '<div id='+options.windowId+' data-define="modal:true,minimizable:false,maximizable:false" style="padding: 0px;">'
		            + iframe + '</div>';
		    $(windowHtml).appendTo(document.body);
	    }
	    window = $("#" + options.windowId);
	    var width = 800;
	    var height = 360;
	    if (options.width) {
		    width = options.width;
	    }
	    if (options.height) {
		    height = options.height;
	    }
	    window.window({
	        width : width,
	        height : height,
	        title : options.title
	    });
	    if (options.wtype && options.wtype == "url") {
		    window.window('refresh', options.url);
	    }
	    window.window("center");
	    window.window("open");
    }
    function clearIframe(iframe) {
	    var iframeWindow = iframe.contentWindow;
	    if (iframe) {
		    iframe.src = 'about:blank';
		    iframeWindow.document.write('');
		    iframeWindow.document.clear();
		    //以上可以清除大部分的内存和文档节点记录数了
		    //最后删除掉这个 iframe 就哦咧。
		    iframe.parentNode.removeChild(iframe);
	    }
    }
    //关闭窗口
    function closeWindow(id) {
	    if ($("#" + id).length == 0) {
		    parent.$("#" + id).window("close");
	    } else {
		    $("#" + id).window("close");
	    }
    }
    //显示网页提示信息.
    function showMsg(message, type) {
	    if (type) {
		    if (type == "info") {
			    $.messager.alert(msgStore.sysMsgTitle, message, 'info');
		    }
	    } else {
		    $.messager.alert(msgStore.sysMsgTitle, message, 'info');
	    }
    }
    //确认框
    function confirmMsg(msg, callback) {
	    $.messager.confirm(msgStore.sysMsgTitle, msg, function(r) {
		    callback(r);
	    });
    }
    //显示网页提示信息.
    function showMessage(type, msgId) {
	    if (type == "info") {
		    $.messager.alert(msgStore.sysMsgTitle, msgStore[msgId], 'info');
	    }
    }
    //错误信息弹出窗口
    function showErrMsg(responseText) {
	    if ($('.errowWindow').length == 0) {
		    var html = '<div class="errorWindow" title="'+msgStore["exceptionMsg"]+'" data-define="modal:true,minimizable:false,maximizable:false" style="width: 300px; height: 200px; padding: 1px;">'
		            + responseText + '</div>'
		    $(html).appendTo("body").window();
	    }
	    $('.errowWindow').window('open');
    }
    //统一封装调用后台
    function ajaxPost(url, data, callback) {
	    $.ajax({
	        type : 'POST',
	        url : url,
	        data : data,
	        success : callback,
	        error : function(res) {
		        var errMsg = res.responseText;
		        showErrMsg(errMsg);
	        },
	        beforeSend : function() {
		        ajaxLoading();
	        },
	        complete : function() {
		        ajaxLoadEnd();
	        },
	        dataType : "json"
	    });
    }
    //统一封装调用后台,同步模式
    function syncAjaxPost(url, data) {
	    var ch = null;
	    $.ajax({
	        async : false,
	        type : 'POST',
	        url : url,
	        data : data,
	        success : function(rs) {
		        ch = rs;
	        },
	        error : function(res) {
		        var errMsg = res.responseText;
		        showErrMsg(errMsg);
	        },
	        dataType : "text"
	    });
	    return ch;
    }
    //将代码项转换为名称显示
    function getComboNameByCode(code, codeValue) {
	    var url = '${rc.contextPath}/getComboNameByCode.do';
	    var data = {
	        "codeId" : code,
	        "codeValue" : codeValue
	    };
	    return syncAjaxPost(url, data);
    }
    //统一封装调用提交表单信息
    function submitForm(formId, url, callback) {
	    ajaxLoading();
	    $("#" + formId).form('submit', {
	        url : url,
	        success : function(rs) {
		        callback(rs);
		        ajaxLoadEnd();
	        }
	    });
    }
    function addTab(title, href, icon, type) {
	    if (type == undefined || type == null || type == "") {
		    addTabByHref(title, href, icon);
	    } else if (type == "1") {
		    addTabByContent(title, href, icon);
	    }
    }
    function addTabByHref(title, href, icon) {
	    var tt = $('#bsTabs');
	    if (tt.tabs('exists', title)) {
		    tt.tabs('select', title);
		    var tab = $('#bsTabs').tabs('getSelected');
		    if (tab) {
			    var index = $('#bsTabs').tabs('getTabIndex', tab);
			    $('#bsTabs').tabs('close', index);
		    }
	    }
	    var content = "";
	    if (href) {
		    tt.tabs('add', {
		        title : title,
		        closable : true,
		        href : href,
		        iconCls : icon || 'icon-default'
		    });
	    } else {
		    tt.tabs('add', {
		        title : title,
		        closable : true,
		        content : "请输入请求地址!",
		        iconCls : icon || 'icon-default'
		    });
	    }
    }
    function addTabByContent(title, href, icon) {
	    var tt = $('#bsTabs');
	    if (tt.tabs('exists', title)) {
		    tt.tabs('select', title);
	    } else {
		    var content = "";
		    if (href) {
			    ajaxLoading();
			    $.get(href, function(dom) {
				    var i1 = dom.indexOf("<body>");
				    var i2 = dom.indexOf("</body>");
				    var bodyHtml = dom.substr(i1 + 6, i2 - i1 - 6);
				    tt.tabs('add', {
				        title : title,
				        closable : true,
				        content : bodyHtml,
				        iconCls : icon || 'icon-default'
				    });
			    });
		    } else {
			    tt.tabs('add', {
			        title : title,
			        closable : true,
			        content : "请输入请求地址!",
			        iconCls : icon || 'icon-default'
			    });
		    }
	    }
    }
</script>